
import { EquipmentType } from "core/typeDefine/typeDefine"
import { FighterModel } from "./fighterModel"
import { ItemModel } from "./itemModel"
import { EquipmentsModel } from "./equipmentsModel"

export class EquipmentsLvlupModel {
    [EquipmentType.Weapon]: number
    [EquipmentType.SubWeapon]: number
    [EquipmentType.Body]: number
    [EquipmentType.Waist]: number
    [EquipmentType.Shoulder]: number
    [EquipmentType.Foot]: number
    [EquipmentType.Leg]: number
    [EquipmentType.Head]: number
    [EquipmentType.Ring]: number
    [EquipmentType.Earring]: number
    [EquipmentType.Necklace]: number
    [EquipmentType.Wings]: number
    constructor(opts: any = {}) {
        this[EquipmentType.Weapon] = opts[EquipmentType.Weapon] || 0
        this[EquipmentType.SubWeapon] = opts[EquipmentType.SubWeapon] || 0
        this[EquipmentType.Body] = opts[EquipmentType.Body] || 0
        this[EquipmentType.Foot] = opts[EquipmentType.Foot] || 0
        this[EquipmentType.Head] = opts[EquipmentType.Head] || 0
        this[EquipmentType.Ring] = opts[EquipmentType.Ring] || 0
        this[EquipmentType.Earring] = opts[EquipmentType.Earring] || 0
        this[EquipmentType.Necklace] = opts[EquipmentType.Necklace] || 0
        this[EquipmentType.Wings] = opts[EquipmentType.Wings] || 0
        this[EquipmentType.Waist] = opts[EquipmentType.Waist] || 0
        this[EquipmentType.Shoulder] = opts[EquipmentType.Shoulder] || 0
        this[EquipmentType.Leg] = opts[EquipmentType.Leg] || 0
    }
}



export class EquipmentsGemModel {
    [EquipmentType.Weapon]: ItemModel[]
    [EquipmentType.SubWeapon]: ItemModel[]
    [EquipmentType.Body]: ItemModel[]
    [EquipmentType.Waist]: ItemModel[]
    [EquipmentType.Shoulder]: ItemModel[]
    [EquipmentType.Foot]: ItemModel[]
    [EquipmentType.Leg]: ItemModel[]
    [EquipmentType.Head]: ItemModel[]
    [EquipmentType.Ring]: ItemModel[]
    [EquipmentType.Earring]: ItemModel[]
    [EquipmentType.Necklace]: ItemModel[]
    [EquipmentType.Wings]: ItemModel[]
    constructor(opts: any = {}) {
        this[EquipmentType.Weapon] = opts[EquipmentType.Weapon] || []
        this[EquipmentType.SubWeapon] = opts[EquipmentType.SubWeapon] || []
        this[EquipmentType.Body] = opts[EquipmentType.Body] || []
        this[EquipmentType.Foot] = opts[EquipmentType.Foot] || []
        this[EquipmentType.Head] = opts[EquipmentType.Head] || []
        this[EquipmentType.Ring] = opts[EquipmentType.Ring] || []
        this[EquipmentType.Earring] = opts[EquipmentType.Earring] || []
        this[EquipmentType.Necklace] = opts[EquipmentType.Necklace] || []
        this[EquipmentType.Wings] = opts[EquipmentType.Wings] || []
        this[EquipmentType.Waist] = opts[EquipmentType.Waist] || []
        this[EquipmentType.Shoulder] = opts[EquipmentType.Shoulder] || []
        this[EquipmentType.Leg] = opts[EquipmentType.Leg] || []
    }
}

export class BaseAttriModel {
    str: number
    con: number
    spirit: number
    will: number
    agile: number
    point: number
    lvl: number
    constructor(opts: any = {}) {
        this.str = opts.str || 0
        this.con = opts.con || 0
        this.spirit = opts.spirit || 0
        this.will = opts.will || 0
        this.agile = opts.agile || 0
        this.point = opts.point || 0
        this.lvl = opts.lvl || 0
    }
}
export class EnchantModel {
    mainType: string
    mainLvl: number
    subType: string
    subLvl: number
    constructor(opts: any = {}) {
        this.mainType = opts.mainType || ''
        this.mainLvl = opts.mainLvl || 0
        this.subType = opts.subType || ''
        this.subLvl = opts.subLvl || 0
    }
}
export class EquipmentsEnchantsModel {
    [EquipmentType.Weapon]: EnchantModel
    [EquipmentType.SubWeapon]: EnchantModel
    [EquipmentType.Body]: EnchantModel
    [EquipmentType.Waist]: EnchantModel
    [EquipmentType.Shoulder]: EnchantModel
    [EquipmentType.Foot]: EnchantModel
    [EquipmentType.Leg]: EnchantModel
    [EquipmentType.Head]: EnchantModel
    [EquipmentType.Ring]: EnchantModel
    [EquipmentType.Earring]: EnchantModel
    [EquipmentType.Necklace]: EnchantModel
    [EquipmentType.Wings]: EnchantModel
    constructor(opts: any = {}) {
        this[EquipmentType.Weapon] = opts[EquipmentType.Weapon] ? new EnchantModel(opts[EquipmentType.Weapon]) : null
        this[EquipmentType.SubWeapon] = opts[EquipmentType.SubWeapon] ? new EnchantModel(opts[EquipmentType.SubWeapon]) : null
        this[EquipmentType.Body] = opts[EquipmentType.Body] ? new EnchantModel(opts[EquipmentType.Body]) : null
        this[EquipmentType.Foot] = opts[EquipmentType.Foot] ? new EnchantModel(opts[EquipmentType.Foot]) : null
        this[EquipmentType.Head] = opts[EquipmentType.Head] ? new EnchantModel(opts[EquipmentType.Head]) : null
        this[EquipmentType.Ring] = opts[EquipmentType.Ring] ? new EnchantModel(opts[EquipmentType.Ring]) : null
        this[EquipmentType.Earring] = opts[EquipmentType.Earring] ? new EnchantModel(opts[EquipmentType.Earring]) : null
        this[EquipmentType.Necklace] = opts[EquipmentType.Necklace] ? new EnchantModel(opts[EquipmentType.Necklace]) : null
        this[EquipmentType.Wings] = opts[EquipmentType.Wings] ? new EnchantModel(opts[EquipmentType.Wings]) : null
        this[EquipmentType.Waist] = opts[EquipmentType.Waist] ? new EnchantModel(opts[EquipmentType.Waist]) : null
        this[EquipmentType.Shoulder] = opts[EquipmentType.Shoulder] ? new EnchantModel(opts[EquipmentType.Shoulder]) : null
        this[EquipmentType.Leg] = opts[EquipmentType.Leg] ? new EnchantModel(opts[EquipmentType.Leg]) : null
    }
}


export class PartnerModel {
    tid: number
    lvl: number
    starLvl: number
    starSkillUnlock: number[]//进阶技能已经解锁的序号
    indexID: number
    equipmentActive: number
    equipments?: EquipmentsModel[]
    equipmentsGem?: EquipmentsGemModel
    equipmentsStr: EquipmentsLvlupModel
    skillList: ItemModel[]
    lskillList: number[]
    skillLvls: any
    baseAttris: BaseAttriModel
    power: number
    pet: ItemModel
    equipmentsEnchants: EquipmentsEnchantsModel
    // pets: ParnterPetsModel
    constructor(opts: any = {}) {
        this.tid = opts.tid || 0
        this.lvl = opts.lvl || 1
        this.starLvl = opts.starLvl || 0
        this.starSkillUnlock = opts.starSkillUnlock || []
        this.indexID = opts.indexID || 1
        this.equipmentActive = opts.equipmentActive || 0
        // this.equipments = opts.equipments || []
        // for (let i = 0; i < 3; i++) {
        //     let item = this.equipments[i]
        //     this.equipments[i] = new EquipmentsModel(item)
        // }
        // this.equipmentsGem = new EquipmentsGemModel(opts.equipmentsGem)
        this.equipmentsStr = new EquipmentsLvlupModel(opts.equipmentsStr)
        this.skillList = opts.skillList || []
        this.lskillList = opts.lskillList || []
        this.skillLvls = opts.skillLvls || {}
        this.baseAttris = new BaseAttriModel(opts.baseAttris)
        this.power = opts.power || 0
        this.pet = opts.pet ? new ItemModel(opts.pet) : null
        this.equipmentsEnchants = new EquipmentsEnchantsModel(opts.equipmentsEnchants)
        // this.pets = new ParnterPetsModel(opts.pets)
    }
}